package com.turing.data.scripts.contract.transfer

import com.turing.common.util.FileUtils
import com.turing.common.util.StringUtils
import com.turing.data.engine.CombineLongText
import com.turing.data.vo.out.review.DependParamsVO
import com.turing.data.vo.out.review.TaskElementVO

class IfInvestmentConsultant_30208_10_transfer {


    static List< TaskElementVO.DrawResultVO > doConvert(List< TaskElementVO.DrawResultVO > resultVOs, DependParamsVO dependParams){

        def Regex_NO1 = /.*未.*/
        def Regex2_NO2 = /.*不.*/
        def Regex3_NO3 = /.*没.*/
        def Regex_HAS_1 = /.*聘请.*/
        def Regex_HAS_2 = /.*作为.*/
        def Regex_NOT_HAS_4 = /.*投资顾问.*如有.*/

        def textPathMap = dependParams.textPathMap
        if (resultVOs!=null && resultVOs.size()>0){
            for (int i = 0; i < resultVOs.size(); i++) {
                if(StringUtils.isEmpty(resultVOs.get(i).childTaskSn)){
                    resultVOs.get(i).setBusinessValue("否")
                    resultVOs.get(i).setType(1)
                    continue
                }
                def rawPath = textPathMap.get(resultVOs.get(i).childTaskSn)
                def rawText = FileUtils.loadJson(rawPath)
                String trueValue = CombineLongText.fetchNearbyText(resultVOs.get(i), rawText,30)
                String modelValue = resultVOs.get(i).getText()
                if(trueValue =~ Regex_NOT_HAS_4){
                    resultVOs.get(i).setBusinessValue("否")
                    resultVOs.get(i).setType(1)
                }else if ( modelValue != null && modelValue != "" ) {
                    if( modelValue =~ Regex_NO1 || modelValue =~ Regex2_NO2 || modelValue =~ Regex3_NO3 ){
                        resultVOs.get(i).setBusinessValue("否")
                        resultVOs.get(i).setType(1)
                    }else if( modelValue =~ Regex_HAS_1 || modelValue =~ Regex_HAS_2  ){
                        resultVOs.get(i).setBusinessValue("是")
                        resultVOs.get(i).setType(1)
                    }else{
                        resultVOs.get(i).setBusinessValue("否")
                        resultVOs.get(i).setType(1)
                    }
                }else {
                    resultVOs.get(i).setBusinessValue("否")
                    resultVOs.get(i).setType(1)
                }
            }
        }

        return resultVOs
    }



}
